home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2004 #11
/
Amiga Plus CD - 2004 - No. 11.iso
/
AmiSoft
/
Comm
/
irc
/
Mail.lha
/
Mail.amirx
next >
Wrap
Text File
|
2004-07-18
|
3KB
|
121 lines
/* Mail.amirx (12.07.04) ©2004 Michael Trebilcock */
Parse Arg Args
Args2=Upper(Args)
Parse Var Args2 CMD" "CMD2" "CMD3
CR="0D"x
/* Configuration */
User="youneed" /* Your login name */
Pass="tofill" /* Your password */
POP3="" /* POP3 address */
Port="theseout" /* POP3 port number */
/* End Configuration */
IF POP3="" THEN Call cEcho("You need to configure this script before you can use it",1)
Call cEcho("Connecting to mail server...")
IF ~Open(TCP,"TCP:"POP3"/"Port,"RW") THEN DO;Call cEcho("Can't connect to "POP3"...");Exit;End
Call cEcho("Connected, awaiting welcome message...")
IF Word(ReadLn(TCP),1)~="+OK" THEN Call cEcho(POP3 "is not a mail server.",1)
Call cEcho("Sending user ID...")
Call WriteLn(TCP,"USER "User)
IF Word(ReadLn(TCP),1)~="+OK" THEN Call cEcho("Invalid user ID...",1)
Call cEcho("Sending password...")
Call WriteLn(TCP,"PASS "Pass)
IF Word(ReadLn(TCP),1)~="+OK" THEN Call cEcho("Invalid password...",1)
IF CMD="DEL" THEN DO
IF CMD2="ALL" THEN DO
Call GStat()
IF Amount="0" THEN Call cEcho("You have no emails to delete...",1)
IF CMD3="" THEN CMD3=Amount
Args="DEL"
DO i=1 TO CMD3
Args=Args" "i
End
End
Amount=SubStr(Args,5)
DO i=1 TO Words(Amount)
Call WriteLn(TCP,"DELE "Word(Amount,i))
IF Word(ReadLn(TCP),1)~="+OK" THEN DO;Call cEcho("Couldn't delete email "Word(Amount,i)"...");End
ELSE DO;Call cEcho("Deleted email "Word(Amount,i)"...");End
End
Call Disconn()
End
Call cEcho("Getting statistics...")
Call GStat()
IF Amount="0" THEN Call cEcho("You have no new emails...",1)
Call cEcho("You have "Amount" new email(s), "Bytes" bytes total...")
IF CMD="VERBOSE" THEN DO
Call WriteLn(TCP,"LIST")
IF Word(ReadLn(TCP),1)~="+OK" THEN Call cEcho("Unable to grab byte sizes...",1)
i=1
Output=Strip(ReadLn(TCP),,CR)
DO UNTIL Output="."
LIST.i=Word(Output,2)
Output=Strip(ReadLn(TCP),,CR)
i=i+1
End
DO i=1 TO Amount
drop From
drop Subject
drop Attaches
Call WriteLn(TCP,"TOP "i" 1")
IF Word(ReadLn(TCP),1)~="+OK" THEN Call cEcho("Unable to grab email information...",1)
DO UNTIL Output="."
Output=Strip(ReadLn(TCP),,CR)
UOut=Word(Upper(Output),1)
IF UOut="FROM:" THEN From=SubStr(Output,7)
IF UOut="SUBJECT:" THEN Subject=SubStr(Output,10)
IF UOut="CONTENT-TYPE"&Word(Output,2)="multipart/mixed;" THEN Attaches="yes"
End
IF From=""|From="FROM" THEN From="<unknown> "
IF Subject=""|Subject="SUBJECT" THEN Subject="<unknown> "
IF Attaches=""|Attaches="ATTACHES" THEN Attaches="no"
Call cEcho(""i". From: "DecISO(From)" Subject: "DecISO(Subject)" Size: "LIST.i" Attachment(s): "Attaches)
End
End
Call Disconn()
cEcho:
"ECHO P="d2c(27)"b«Mail» "Arg(1)
IF Arg(2)="1" THEN Call Disconn()
Return 0
Disconn:
Call cEcho("Disconnecting...")
Call WriteLn(TCP,"QUIT")
Call Close(TCP)
Exit
GStat:
Call WriteLn(TCP,"STAT")
Output=Strip(ReadLn(TCP),,CR)
IF Word(Output,1)~="+OK" THEN Call cEcho("Unable to get statistics...",1)
Parse Var Output Ok" "Amount" "Bytes
Return 0
DecISO:
Text=Arg(1)
DO UNTIL First=Text
Parse Var Text First"=?"Header"?"Type"?"Encode"?="Rest
IF Type="Q" THEN DO
Text2=""
DO UNTIL Encode2=""
Parse Var Encode First2"="Encode2
Encode3=x2c(Left(Encode2,2))
Text2=Text2""First2""Encode3
Encode=SubStr(Encode2,3)
End
Text=First""Text2""Rest
End
ELSE First=Text
End
Return Text
Syntax:
Call cEcho("Command on line" SIGL "returned" RC ":" errortext(rc) sourceline(SIGL))
Exit